home *** CD-ROM | disk | FTP | other *** search
/ PC-X 1997 October / pcx14_9710.iso / swag / delphi.swg / 0220_Execute a program to link to another pro.pas < prev    next >
Encoding:
Pascal/Delphi Source File  |  1997-03-04  |  1.4 KB  |  58 lines

  1. {
  2. >>        I'm trying to make a progam which can call WINWORD.EXE for =
  3. example
  4. >>when
  5. >>you select a file with a ".DOC" extension.... I have look at the =
  6. WIN.INI
  7. >>file in the EXTENSION section but this solution was not very clean =
  8. !!!!
  9. >>
  10. >>        Can somebody please help me?
  11. >
  12. >Use ShellExecute and set "Operation" to 'Open'.
  13.  
  14.  
  15.         I have found a solution more easy to used.
  16.         I use a TOleContainer object like this :
  17. }
  18. unit Unit1;
  19.  
  20. interface
  21.  
  22. uses
  23.   Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms,
  24. Dialogs,
  25.   StdCtrls, Buttons, OleCtnrs;
  26.  
  27. type
  28.   TForm1 =3D class(TForm)
  29.     OleContainer1: TOleContainer;
  30.     BitBtn1: TBitBtn;
  31.     procedure BitBtn1Click(Sender: TObject);
  32.   private
  33.     { D=E9clarations priv=E9es }
  34.   public
  35.     { D=E9clarations publiques }
  36.   end;
  37.  
  38. var
  39.   Form1: TForm1;
  40.  
  41. implementation
  42.  
  43. {$R *.DFM}
  44.  
  45. procedure TForm1.BitBtn1Click(Sender: TObject);
  46. begin
  47.   OleContainer1.CreateLinkToFile('C:\TEST\TOTO.doc', False);      {
  48.      You specify your file name            }
  49.   OleContainer1.DoVerb(ovShow);                                 { Like that the application called
  50. was open }
  51.   OleContainer1.CreateLinkToFile('C:\TEST\TITI.doc', False);
  52.   OleContainer1.DoVerb(ovShow);
  53.   OleContainer1.CreateLinkToFile('C:\WINDOWS\WIN.INI', False);
  54.   OleContainer1.DoVerb(ovShow);=09
  55. end;
  56.  
  57. end.
  58.